package com.icesoft.system.safe.helper;

import com.icesoft.system.safe.utils.AesUtil;
import com.icesoft.system.safe.utils.KeyPairUtils;
import com.icesoft.system.safe.utils.RsaUtil;

import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;

public class RsaAesCryptoHelper {

	public static String publicEncrypt(String publicKey, String data) {
		RSAPublicKey rsaPublicKey = (RSAPublicKey) KeyPairUtils.getPublicKey(publicKey);
		return RsaUtil.encryptWithBase64(rsaPublicKey, data);
	}

	public static String privateDecrypt(String privateKey, String data) {
		RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) KeyPairUtils.getPrivateKey(privateKey);
		return RsaUtil.decryptWithBase64(rsaPrivateKey, data);
	}

	public static String symmetricEncrypt(String key, String data) {
		return AesUtil.encrypt(key, data);
	}

	public static String symmetricDecrypt(String key, String data) {
		return AesUtil.decrypt(key, data);
	}

}
